<?php

//Classe représentant une donnée de la table FILM
class Film extends Entity { use FilmView;
	
	
	//Nom de la table
	protected static $sql_table='film';
	//Colonne utilisée comme identifiant
	protected static $sql_id='FILM_NUMID';
	
	
	
	//Liste des colonnes de la table
	protected $FILM_NUMID;
	protected $FILM_TITRE;
	protected $GENR_NUMID;
	protected $AVER_NUMID;
	protected $FILM_DUREE;
	protected $FILM_SORTI;
	protected $FILM_AFFIC;
	protected $FILM_SYNOP;
	
	
	
	//Initialisation des données non nullable en base
	public function __construct(){
		if($this->FILM_DUREE===null) $this->FILM_DUREE = 0;
		if($this->FILM_SORTI===null) $this->FILM_SORTI = date('Y-m-d');
		if($this->FILM_SYNOP===null) $this->FILM_SYNOP = '';
	}
	
	
	
	public function delete(){
            $retour=parent::delete();
	    FileSystem::deleteFile($this->FILM_AFFIC);
	    return $retour;
	}
    
    
    public function populateFile($file){
        Message::debug('Populate '.$file);
        if($file=='FILM_AFFIC'){
            $infosImage=Image::check($file);
            if(is_array($infosImage)){
                if($this->FILM_AFFIC) FileSystem::deleteFile($this->FILM_AFFIC);
                $this->FILM_AFFIC=$infosImage['lien'];
            }
        }
    }
	
	

}



?>